<template>
	<view>
		<block v-if="isSearchBar">
 -->		<!-- 搜索栏 -->
		<view class="header" :style="{ position: headerPosition,top:headerTop,opacity: afterHeaderOpacity }">
			<!-- 搜索框 -->
			<view class="input-box">
				<input placeholder="请输入对方的 ID" style="width: 100%;" v-model="message" type="number"  placeholder-style="color:#c0c0c0;"/>
				<view style="display: flex; align-items: center; justify-content: center; margin-right: 20upx;">
				<image @click="saoma()" src="../static/img/saoma.png" mode="" style="width: 40upx; height: 40upx;"></image>
				</view>
			</view>
			<!-- 右侧图标信息 -->
			<view class="icon-btn" @click="toMsg()">
				<image src="../static/img/zhangdan.png" mode=""   class="icon"></image>				
			</view>
		</view>
		<!-- 占位 -->
		</block>
		<block v-else>
			<!-- 普通顶栏栏 -->
			<view class="header" :style="{ position: headerPosition,top:headerTop,opacity: afterHeaderOpacity }">
				<view @click="goBack">返回</view>
				<view class="title"> {{title}} </view>
			</view>
		</block>
		<!-- <view class="place"></view> -->
	</view>
</template>

<script>
	//高德SDK
	import amap from '@/common/SDK/amap-wx.js';
	export default {
		props: ['isSearchBar', 'hasBack', 'title'],
		data() {
			return {
				afterHeaderOpacity: 1, //不透明度
				headerPosition: 'fixed',
				headerTop: 0,
				statusTop: null,
				city: '--',
				message:""
			};
		},
		onLoad() {
			// #ifdef APP-PLUS
			this.statusHeight = plus.navigator.getStatusbarHeight();
			// #endif
			this.amapPlugin = new amap.AMapWX({
				//高德地图KEY，随时失效，请务必替换为自己的KEY，参考：http://ask.dcloud.net.cn/article/35070
				key: '7c235a9ac4e25e482614c6b8eac6fd8e'
			});
			//定位地址
			this.amapPlugin.getRegeo({
				success: data => {
					this.city = data[0].regeocodeData.addressComponent.city.replace(/市/g, ''); //把"市"去掉
				},
				fail: data => {
					console.log(data)
				}
			});
		},
		methods: {
			//消息列表
			toMsg() {
				console.log("1")
				uni.navigateTo({
					url: '/pages/user/mydep/zhangList?type=1'
				})
			},
			saoma(){
				var that = this
				uni.scanCode({
				    success: function (res) {
				        console.log('条码类型：' + res.scanType);
				        console.log('条码内容：' + res.result);
						that.message = res.result
				    }
				});
			},
			//搜索跳转
			toSearch() {
				
			},
			goBack() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #f0f0f0;
		
	}

	.icon {
		font-size: 60upx;
		font-style: normal;
		color: #000000;
	}

	.status {
		width: 100%;
		height: 0;
		position: fixed;
		z-index: 10;
		background-color: #f0f0f0;
		top: 0;
		/*  #ifdef  APP-PLUS  */
		height: var(--status-bar-height); //覆盖样式
		/*  #endif  */

	}

	.header {
		width: 92%;
		padding: 0 4%;
		height: 100upx;
		display: flex;
		align-items: center;
		position: fixed;
		top: 0;
		z-index: 10;
		
		background-color: $pin-color-primary;
		/*  #ifdef  APP-PLUS  */
		top: var(--status-bar-height);
		/*  #endif  */

		.addr {
			width: 120upx;
			height: 60upx;
			flex-shrink: 0;
			display: flex;
			align-items: center;
			font-size: 28upx;
			color: $pin-color-foreground;

			.icon {
				height: 60upx;
				margin-right: 5upx;
				display: flex;
				align-items: center;
				font-size: 42upx;
				color: $pin-color-foreground;
			}
		}

		.input-box {
			width: 100%;
			height: 60upx;
			background-color: #f5f5f5;
			border-radius: 10upx;
			position: relative;
			display: flex;
			align-items: center;

			.icon {
				display: flex;
				align-items: center;
				position: absolute;
				top: 0;
				right: 0;
				width: 60upx;
				height: 60upx;
				font-size: 34upx;
				color: #c0c0c0;
			}

			input {
				padding-left: 28upx;
				height: 28upx;
				font-size: 28upx;
			}
		}

		.icon-btn {
			width: 100rpx;
			height: 100%;
			margin-left: 20upx;
			// flex-shrink: 0;
			display: flex;
			justify-content: center;
			align-items: center;

			.icon {
				width: 39rpx;
				height: 44rpx;
			}
		}
	}

	.place {
		background-color: #ffffff;
		height: 100upx;
		/*  #ifdef  APP-PLUS  */
		margin-top: var(--status-bar-height);
		/*  #endif  */
	}
</style>
